﻿using System;

namespace GCommon
{
    public struct ResourceID: IEquatable<ResourceID>
    {
        private readonly uint m_Value;
        private ResourceID(uint value)
        {
            this.m_Value = value;
        }
        public static implicit operator uint(ResourceID id)
        {
            return id.m_Value;
        }
        public static implicit operator ResourceID(uint value)
        {
            ResourceID id = new ResourceID(value);
            return id;
        }
        public static bool operator ==(ResourceID a, ResourceID b)
        {
            return a.m_Value == b.m_Value;
        }
        public static bool operator !=(ResourceID a, ResourceID b)
        {
            return a.m_Value != b.m_Value;
        }
        public override string ToString()
        {
            return m_Value.ToString();
        }
        public bool Equals(ResourceID other)
        {
            return m_Value == other.m_Value;
        }
        public override bool Equals(object obj)
        {
            if (obj.GetType() != typeof(ResourceID))
                return false;

            ResourceID id = (ResourceID)obj;
            return id.m_Value == this.m_Value;
        }
        public override int GetHashCode()
        {
            return m_Value.GetHashCode();
        }
        public static readonly ResourceID INVALID = 0xffffffff;
    }
}

